<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="content">
        <f:view beforePhase="#{addSaleInquiryManagerBean.initView2}">
        
        <h:form prependId="false">
            <p:panel id="panel" header="Add New Sale Inquiry"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus>
                
                <p:messages /> 
                
                <h:outputLabel for="saleLeadName" style="font-weight: bold" value="Company Name: "/>
                <h:outputText value="#{addSaleInquiryManagerBean.selectedSaleLead.saleLeadName}" id="saleLeadName"/>
                <p:message for="saleLeadName"/>
                
                <h:outputLabel for="customDiscount" style="font-weight: bold" value="Custom Discount: "/>
                <h:inputText value="#{addSaleInquiryManagerBean.customDiscount}" id="customDiscount"/>
                <p:message for="customDiscount"/>
                
                <p:spacer height="15"/>
                <p:dataTable var="lineItem" value="#{addSaleInquiryManagerBean.lineItems}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type">
                    
                    <p:column sortBy="#{lineItem.productPrice.productType}">
                        <f:facet name="header">
                            <h:outputText value="Type"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.productPrice.productType}"/>
                    </p:column>
                    
                    <p:column sortBy="#{lineItem.productPrice.productPrice}">
                        <f:facet name="header">
                            <h:outputText value="Price per Unit"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.productPrice.productPrice}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:inputText id ="quantity" value="#{lineItem.lineItemQuantity}">                      
                        </h:inputText>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Volume Discount"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.volumeDiscountRate}"/>                        
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Total Price"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.finalPrice}"/>
                    </p:column>
                </p:dataTable>
         
                <p:commandButton id="btn" value="Save New Sale Inquiry" update="panel" actionListener="#{addSaleInquiryManagerBean.saveSaleInquiryFromSaleLead}" ajax="true" />
                <p:commandButton value="Refresh Price" update="panel" actionListener="#{addSaleInquiryManagerBean.calculate}" ajax="true"/>
            </p:panel> 
        </h:form>
        </f:view>
    </ui:define>

</ui:composition>
